package com.maoye.ossp.bpm.bpmweb.controller.executor;

import com.maoye.ossp.bpm.bpmweb.utils.DataHolder;

/**
 * 流程调用执行对象
 * 
 * @author hedh
 * 
 */
public abstract class BpmxExecutor {
	/**
	 * 执行操作
	 * 
	 * @param holder
	 * @return
	 */
	public String execute(DataHolder holder) {
		String result = null;

		try {
			if (holder != null && !holder.hasError() && holder.finished()) {
				result = doExecute(holder);
			}
		} catch (Exception e) {
			result = String.format("{\"code\":\"1002\",\"msg\":\"%s\"}",
					e.getMessage());
		}

		holder.clear();
		return result;
	}

	public abstract String doExecute(DataHolder holder);
}
